<h1>Cart contains:</h1>
<ul>
<?php

foreach ($cartitems as $itemid){ ?>
    <li><?php echo $itemid; ?></li>
<?php }
?>
</ul>